/*
 * Equation.h
 *
 *  Created on: May 7, 2011
 *      Author: trungtq
 */

#ifndef EQUATION_H_
#define EQUATION_H_

#include <map>

#include "Term.h"
#include "string"

/* class define the equation a=b, f(x)=f(y), a=f(x) ...*/

class Equation {
public:
    Equation();
    Equation(Term leftSide, Term rightSide);
    virtual ~Equation();

private:
    Term leftSide;
    Term rightSide;

public:
    static const Equation NULLEquation;

public:
    // getter & settter
    Term getLeftSide() const;
    Term getRightSide() const;
    void setLeftSide(Term leftSide);
    void setRightSide(Term rightSide);

public:
    string toString() const;
    bool isNULL() const;

public:
    static Equation parseString(string equationString, FunctionSet *funcSet, VariableSet *varSet);
};

/* class define for comparable operation between 2 equation when executing flatten */
class EquationCompare {
public:
    bool operator() (Equation eq1, Equation eq2) {
        string s1 = eq1.getLeftSide().toString();
        string s2 = eq2.getLeftSide().toString();
        return (s1.compare(s2) < 0);
    }
};

typedef set<Equation, EquationCompare>        EquationSet;
typedef vector<Equation>                      EquationList;



#endif /* EQUATION_H_ */
